using System;

using Gurucore.Framework.Core;

namespace Gurucore.Framework.DataAccess.Persistence.QueryLanguage
{
	public class ColumnOperand : Operand
	{
		private string m_sTableName;
		private string m_sColumnName;

		public string FullName
		{
			get 
			{
				DataAccessContext oDACtx = DataAccessContext.GetDataAccessContext();
				
				TableInfoManager oTableInfoMgr = Application.GetInstance().GetGlobalSharedObject<TableInfoManager>();
				TableInfo tableInfo = oTableInfoMgr.GetTableInfo(m_sTableName);
				string sTablePrefix = tableInfo.UseTablePrefix ? oDACtx.GetTablePrefix() : string.Empty;

				return sTablePrefix + m_sTableName + "." + m_sColumnName; 
			}
		}

		public string ShortName
		{
			get { return m_sColumnName; }
		}

		public ColumnOperand(string p_sTableName, string p_sColumnName)
		{
			m_sTableName = p_sTableName;
			m_sColumnName = p_sColumnName;
		}

		public override string ToExpressionString(IExpressionMaker p_oExpressionMaker)
		{
			return FullName;
		}
	}
}
